package tsing.javase.designpattern.responsebility;

import org.springframework.stereotype.Component;


/**
 * 放入责任链
 */
@Component
public class ApprovalHandlerChain {



    private GroupLeaderApprovalHandler groupLeaderApprovalHandler = new GroupLeaderApprovalHandler();

    private DirectorApprovalHandler directorApprovalHandler = new DirectorApprovalHandler();

    private HrApprovalHandler hrApprovalHandler = new HrApprovalHandler();

    public ApprovalHandler getChain() {
        //组长处理完下一个处理对象是主管
        groupLeaderApprovalHandler.nextHandler(directorApprovalHandler);
        //主管处理完下一个处理对象是hr
        directorApprovalHandler.nextHandler(hrApprovalHandler);

        //返回组长，这样就从组长开始审批，一条链就完成了
        return groupLeaderApprovalHandler;
    }

}
